home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12278 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: news.uninet.net!usenet
  2. From: uni00128@uninet.net (Eric Benton)
  3. Newsgroups: alt.comp.lang.borland-delphi,comp.lang.basic.visual.misc,comp.lang.c++,comp.os.ms-windows.misc,comp.os.ms-windows.programmer.misc,comp.windows.misc
  4. Subject: Drag From File Manger to VB
  5. Date: Tue, 19 Mar 96 01:55:38 GMT
  6. Organization: Software Magix
  7. Message-ID: <N.031896.205538.88@anx_p13.uninet.net>
  8. NNTP-Posting-Host: anx_p13.uninet.net
  9. X-Newsreader: Quarterdeck Message Center [1.1]
  10.  
  11. Hi,
  12.     Many thanks to all those who answered my other questions on multi-font vbx's 
  13. and
  14. changing the Win startup logo. Sorry I couldn't write a thanks to you all. 
  15. New Question:
  16.      I would like to Drag a file from File Manager to VB. I am working with 
  17.  
  18. Declare Sub DragAcceptfiles Lib "Shell.dll" (ByVal hWnd As Integer, ByVal Accept 
  19. As Integer)
  20. Declare Function DragQueryFile Lib "Shell.dll" (ByVal hDrop As Integer, ByVal 
  21. iFile As Integer, lpszFile$, ByVal cb As Integer) As Integer
  22.  
  23. 'HDROP hDrop;   /* handle of structure for dropped files  */
  24. 'UINT iFile; /* index of file to query  */ -1 to get count
  25. 'LPSTR lpszFile;   /* address of buffer for returned filename   */
  26. 'UINT cb; /* size of buffer for filename   */
  27.  
  28. ' example code from .hlp file
  29. 'POINT pt;
  30. 'WORD cFiles, a;
  31. 'char szFile[80];
  32.  
  33. 'DragQueryPoint((HANDLE) wParam, &pt);
  34.  
  35. 'cFiles = DragQueryFile((HANDLE) wParam, 0xFFFF, (LPSTR) NULL, 0);
  36. 'for(a = 0; a < cFiles; pt.y += 20, a++) {
  37. '    DragQueryFile((HANDLE) wParam, a, szFile, sizeof(szFile));
  38. '    TextOut(hdc, pt.x, pt.y, szFile, strlen(szFile));
  39. '}
  40.  
  41. 'DragFinish((HANDLE) wParam);
  42.  
  43. So I studied this code and ran a few tests. The problem comes in that VB will not 
  44. trigger any events
  45. in response to dragging from the File Manger and Dropping on a form or list box.
  46. I have a vbx called MsgHook.vbx that you use by setting the msg number to true 
  47. that you want to trap.
  48. ie: say you want to trap msgs WM_USER+8 WM_USER+12 and WM_USER+27
  49.       MsgHook.hWndHook = Form1.Hwnd     ' Trap only the following msgs sent to 
  50. Form1
  51.       MsgHook(WM_USER + 8) = True
  52.       MsgHook(WM_USER + 12) = True  
  53.       MsgHook(WM_USER + 27) = True
  54. I thought, well, I'll just trap the appropriate msg and do a DragQueryFile to get 
  55. the Handle and the
  56. file count and then just iterate through the file names in a like manner. 
  57.  
  58. The question is, what Msg do I trap? I cna't seem to 'test it out' by trial and 
  59. error. I additem'd
  60. the incomming msg numbers to a list box but none seem to be specific to the 
  61. dragdrop operation. And
  62. like i said VB won't trigger any. 
  63.                                    Thanks
  64.                                       Eric
  65. ----
  66.  
  67.    uni00128@uninet.net
  68.  
  69.  
  70.